package com.fivium.bpd.editor.renderer;

import java.awt.Color;
import java.awt.Component;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;

import com.fivium.bpd.component.Assignment;
import com.fivium.bpd.component.QueryDefinition;
import com.fivium.bpd.component.QueryDefinition.QUERY_TYPE;

public class AssignmentCellRenderer extends AbstractCellRenderer
    implements ListCellRenderer
{
  private static final Color HIGHLIGHT_COLOR = new Color(0, 0, 128);
 
  private static ImageIcon iconProcess;
  private static ImageIcon iconContextual;
  private static ImageIcon iconExternal;
  
  public AssignmentCellRenderer()
  {
    super();
    
    if (iconProcess == null) {
      iconProcess = new ImageIcon(getClass().getResource("resource/icon_assignment_process.png"));
    }
    
    if (iconContextual == null) {
      iconContextual = new ImageIcon(getClass().getResource("resource/icon_assignment_contextual.png"));
    }

    if (iconExternal == null) {
      iconExternal = new ImageIcon(getClass().getResource("resource/icon_assignment_external.png"));
    }
  }

  @Override
  protected void buildRenderableContent(Object value)
  {
    Assignment assignment = (Assignment)value;
    
    setText(assignment.getAssignmentTitle());
    
    switch (assignment.getAssignmentType()) {
      case PROCESS:
        setIcon(iconProcess);
        break;
      case CONTEXTUAL:
        setIcon(iconContextual);
        break;
      case EXTERNAL:
        setIcon(iconExternal);
        break;
    }
  }
  
  
}
